Optimal. Leaf size=109 \[ \frac {2 a^2 (i A+B) (c-i c \tan (e+f x))^n}{f n}-\frac {a^2 (i A+3 B) (c-i c \tan (e+f x))^{1+n}}{c f (1+n)}+\frac {a^2 B (c-i c \tan (e+f x))^{2+n}}{c^2 f (2+n)} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.11, antiderivative size = 109, normalized size of antiderivative = 1.00, number of steps
used = 3, number of rules used = 2, integrand size = 41, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.049, Rules used = {3669, 78}
\begin {gather*} \frac {2 a^2 (B+i A) (c-i c \tan (e+f x))^n}{f n}-\frac {a^2 (3 B+i A) (c-i c \tan (e+f x))^{n+1}}{c f (n+1)}+\frac {a^2 B (c-i c \tan (e+f x))^{n+2}}{c^2 f (n+2)} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 78
Rule 3669
Rubi steps
\begin {align*} \int (a+i a \tan (e+f x))^2 (A+B \tan (e+f x)) (c-i c \tan (e+f x))^n \, dx &=\frac {(a c) \text {Subst}\left (\int (a+i a x) (A+B x) (c-i c x)^{-1+n} \, dx,x,\tan (e+f x)\right )}{f}\\ &=\frac {(a c) \text {Subst}\left (\int \left (2 a (A-i B) (c-i c x)^{-1+n}-\frac {a (A-3 i B) (c-i c x)^n}{c}-\frac {i a B (c-i c x)^{1+n}}{c^2}\right ) \, dx,x,\tan (e+f x)\right )}{f}\\ &=\frac {2 a^2 (i A+B) (c-i c \tan (e+f x))^n}{f n}-\frac {a^2 (i A+3 B) (c-i c \tan (e+f x))^{1+n}}{c f (1+n)}+\frac {a^2 B (c-i c \tan (e+f x))^{2+n}}{c^2 f (2+n)}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 2.66, size = 146, normalized size = 1.34 \begin {gather*} \frac {a^2 e^{n (-\log (c \sec (e+f x))+\log (c-i c \tan (e+f x)))} \sec ^2(e+f x) (c \sec (e+f x))^n \left ((2+n) (-B (-2+n)+i A (2+n))+\left (i A (2+n)^2+B \left (4+2 n+n^2\right )\right ) \cos (2 (e+f x))-n (A (2+n)-i B (4+n)) \sin (2 (e+f x))\right )}{2 f n (1+n) (2+n)} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 1.49, size = 167, normalized size = 1.53
method | result | size |
norman | \(\frac {\left (i A \,a^{2} n^{2}+4 i A \,a^{2} n +4 i A \,a^{2}+a^{2} B n +4 a^{2} B \right ) {\mathrm e}^{n \ln \left (c -i c \tan \left (f x +e \right )\right )}}{f n \left (1+n \right ) \left (2+n \right )}-\frac {a^{2} B \left (\tan ^{2}\left (f x +e \right )\right ) {\mathrm e}^{n \ln \left (c -i c \tan \left (f x +e \right )\right )}}{f \left (2+n \right )}-\frac {a^{2} \left (-i B n +A n -4 i B +2 A \right ) \tan \left (f x +e \right ) {\mathrm e}^{n \ln \left (c -i c \tan \left (f x +e \right )\right )}}{f \left (1+n \right ) \left (2+n \right )}\) | \(167\) |
risch | \(\text {Expression too large to display}\) | \(2499\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [B] Both result and optimal contain complex but leaf count of result is larger than
twice the leaf count of optimal. 689 vs. \(2 (102) = 204\).
time = 0.65, size = 689, normalized size = 6.32 \begin {gather*} \frac {2 \, {\left ({\left ({\left (A + i \, B\right )} a^{2} c^{n} n^{2} + 4 \, A a^{2} c^{n} n + 4 \, {\left (A - i \, B\right )} a^{2} c^{n}\right )} 2^{n} \cos \left (-2 \, f x + n \arctan \left (\sin \left (2 \, f x + 2 \, e\right ), \cos \left (2 \, f x + 2 \, e\right ) + 1\right ) - 2 \, e\right ) + {\left ({\left (A - i \, B\right )} a^{2} c^{n} n^{2} + 3 \, {\left (A - i \, B\right )} a^{2} c^{n} n + 2 \, {\left (A - i \, B\right )} a^{2} c^{n}\right )} 2^{n} \cos \left (-4 \, f x + n \arctan \left (\sin \left (2 \, f x + 2 \, e\right ), \cos \left (2 \, f x + 2 \, e\right ) + 1\right ) - 4 \, e\right ) + {\left ({\left (A + i \, B\right )} a^{2} c^{n} n + 2 \, {\left (A - i \, B\right )} a^{2} c^{n}\right )} 2^{n} \cos \left (n \arctan \left (\sin \left (2 \, f x + 2 \, e\right ), \cos \left (2 \, f x + 2 \, e\right ) + 1\right )\right ) - {\left ({\left (i \, A - B\right )} a^{2} c^{n} n^{2} + 4 i \, A a^{2} c^{n} n + 4 \, {\left (i \, A + B\right )} a^{2} c^{n}\right )} 2^{n} \sin \left (-2 \, f x + n \arctan \left (\sin \left (2 \, f x + 2 \, e\right ), \cos \left (2 \, f x + 2 \, e\right ) + 1\right ) - 2 \, e\right ) - {\left ({\left (i \, A + B\right )} a^{2} c^{n} n^{2} + 3 \, {\left (i \, A + B\right )} a^{2} c^{n} n + 2 \, {\left (i \, A + B\right )} a^{2} c^{n}\right )} 2^{n} \sin \left (-4 \, f x + n \arctan \left (\sin \left (2 \, f x + 2 \, e\right ), \cos \left (2 \, f x + 2 \, e\right ) + 1\right ) - 4 \, e\right ) - {\left ({\left (i \, A - B\right )} a^{2} c^{n} n + 2 \, {\left (i \, A + B\right )} a^{2} c^{n}\right )} 2^{n} \sin \left (n \arctan \left (\sin \left (2 \, f x + 2 \, e\right ), \cos \left (2 \, f x + 2 \, e\right ) + 1\right )\right )\right )}}{{\left ({\left (-i \, n^{3} - 3 i \, n^{2} - 2 i \, n\right )} {\left (\cos \left (2 \, f x + 2 \, e\right )^{2} + \sin \left (2 \, f x + 2 \, e\right )^{2} + 2 \, \cos \left (2 \, f x + 2 \, e\right ) + 1\right )}^{\frac {1}{2} \, n} \cos \left (4 \, f x + 4 \, e\right ) + {\left (n^{3} + 3 \, n^{2} + 2 \, n\right )} {\left (\cos \left (2 \, f x + 2 \, e\right )^{2} + \sin \left (2 \, f x + 2 \, e\right )^{2} + 2 \, \cos \left (2 \, f x + 2 \, e\right ) + 1\right )}^{\frac {1}{2} \, n} \sin \left (4 \, f x + 4 \, e\right ) + {\left (-i \, n^{3} - 3 i \, n^{2} - 2 \, {\left (i \, n^{3} + 3 i \, n^{2} + 2 i \, n\right )} \cos \left (2 \, f x + 2 \, e\right ) + 2 \, {\left (n^{3} + 3 \, n^{2} + 2 \, n\right )} \sin \left (2 \, f x + 2 \, e\right ) - 2 i \, n\right )} {\left (\cos \left (2 \, f x + 2 \, e\right )^{2} + \sin \left (2 \, f x + 2 \, e\right )^{2} + 2 \, \cos \left (2 \, f x + 2 \, e\right ) + 1\right )}^{\frac {1}{2} \, n}\right )} f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [B] Both result and optimal contain complex but leaf count of result is larger than twice
the leaf count of optimal. 211 vs. \(2 (102) = 204\).
time = 4.97, size = 211, normalized size = 1.94 \begin {gather*} -\frac {2 \, {\left ({\left (-i \, A + B\right )} a^{2} n + 2 \, {\left (-i \, A - B\right )} a^{2} + {\left ({\left (-i \, A - B\right )} a^{2} n^{2} + 3 \, {\left (-i \, A - B\right )} a^{2} n + 2 \, {\left (-i \, A - B\right )} a^{2}\right )} e^{\left (4 i \, f x + 4 i \, e\right )} + {\left ({\left (-i \, A + B\right )} a^{2} n^{2} - 4 i \, A a^{2} n + 4 \, {\left (-i \, A - B\right )} a^{2}\right )} e^{\left (2 i \, f x + 2 i \, e\right )}\right )} \left (\frac {2 \, c}{e^{\left (2 i \, f x + 2 i \, e\right )} + 1}\right )^{n}}{f n^{3} + 3 \, f n^{2} + 2 \, f n + {\left (f n^{3} + 3 \, f n^{2} + 2 \, f n\right )} e^{\left (4 i \, f x + 4 i \, e\right )} + 2 \, {\left (f n^{3} + 3 \, f n^{2} + 2 \, f n\right )} e^{\left (2 i \, f x + 2 i \, e\right )}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [B] Both result and optimal contain complex but leaf count of result is larger than twice
the leaf count of optimal. 1482 vs. \(2 (87) = 174\).
time = 1.50, size = 1482, normalized size = 13.60 \begin {gather*} \begin {cases} x \left (A + B \tan {\left (e \right )}\right ) \left (i a \tan {\left (e \right )} + a\right )^{2} \left (- i c \tan {\left (e \right )} + c\right )^{n} & \text {for}\: f = 0 \\- \frac {2 A a^{2} \tan {\left (e + f x \right )}}{2 c^{2} f \tan ^{2}{\left (e + f x \right )} + 4 i c^{2} f \tan {\left (e + f x \right )} - 2 c^{2} f} - \frac {2 i B a^{2} f x \tan ^{2}{\left (e + f x \right )}}{2 c^{2} f \tan ^{2}{\left (e + f x \right )} + 4 i c^{2} f \tan {\left (e + f x \right )} - 2 c^{2} f} + \frac {4 B a^{2} f x \tan {\left (e + f x \right )}}{2 c^{2} f \tan ^{2}{\left (e + f x \right )} + 4 i c^{2} f \tan {\left (e + f x \right )} - 2 c^{2} f} + \frac {2 i B a^{2} f x}{2 c^{2} f \tan ^{2}{\left (e + f x \right )} + 4 i c^{2} f \tan {\left (e + f x \right )} - 2 c^{2} f} + \frac {B a^{2} \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )} \tan ^{2}{\left (e + f x \right )}}{2 c^{2} f \tan ^{2}{\left (e + f x \right )} + 4 i c^{2} f \tan {\left (e + f x \right )} - 2 c^{2} f} + \frac {2 i B a^{2} \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )} \tan {\left (e + f x \right )}}{2 c^{2} f \tan ^{2}{\left (e + f x \right )} + 4 i c^{2} f \tan {\left (e + f x \right )} - 2 c^{2} f} - \frac {B a^{2} \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 c^{2} f \tan ^{2}{\left (e + f x \right )} + 4 i c^{2} f \tan {\left (e + f x \right )} - 2 c^{2} f} + \frac {6 i B a^{2} \tan {\left (e + f x \right )}}{2 c^{2} f \tan ^{2}{\left (e + f x \right )} + 4 i c^{2} f \tan {\left (e + f x \right )} - 2 c^{2} f} - \frac {4 B a^{2}}{2 c^{2} f \tan ^{2}{\left (e + f x \right )} + 4 i c^{2} f \tan {\left (e + f x \right )} - 2 c^{2} f} & \text {for}\: n = -2 \\- \frac {2 A a^{2} f x \tan {\left (e + f x \right )}}{2 c f \tan {\left (e + f x \right )} + 2 i c f} - \frac {2 i A a^{2} f x}{2 c f \tan {\left (e + f x \right )} + 2 i c f} - \frac {i A a^{2} \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )} \tan {\left (e + f x \right )}}{2 c f \tan {\left (e + f x \right )} + 2 i c f} + \frac {A a^{2} \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 c f \tan {\left (e + f x \right )} + 2 i c f} + \frac {4 A a^{2}}{2 c f \tan {\left (e + f x \right )} + 2 i c f} + \frac {6 i B a^{2} f x \tan {\left (e + f x \right )}}{2 c f \tan {\left (e + f x \right )} + 2 i c f} - \frac {6 B a^{2} f x}{2 c f \tan {\left (e + f x \right )} + 2 i c f} - \frac {3 B a^{2} \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )} \tan {\left (e + f x \right )}}{2 c f \tan {\left (e + f x \right )} + 2 i c f} - \frac {3 i B a^{2} \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{2 c f \tan {\left (e + f x \right )} + 2 i c f} - \frac {2 i B a^{2} \tan ^{2}{\left (e + f x \right )}}{2 c f \tan {\left (e + f x \right )} + 2 i c f} - \frac {6 i B a^{2}}{2 c f \tan {\left (e + f x \right )} + 2 i c f} & \text {for}\: n = -1 \\2 A a^{2} x + \frac {i A a^{2} \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{f} - \frac {A a^{2} \tan {\left (e + f x \right )}}{f} - 2 i B a^{2} x + \frac {B a^{2} \log {\left (\tan ^{2}{\left (e + f x \right )} + 1 \right )}}{f} - \frac {B a^{2} \tan ^{2}{\left (e + f x \right )}}{2 f} + \frac {2 i B a^{2} \tan {\left (e + f x \right )}}{f} & \text {for}\: n = 0 \\- \frac {A a^{2} n^{2} \left (- i c \tan {\left (e + f x \right )} + c\right )^{n} \tan {\left (e + f x \right )}}{f n^{3} + 3 f n^{2} + 2 f n} + \frac {i A a^{2} n^{2} \left (- i c \tan {\left (e + f x \right )} + c\right )^{n}}{f n^{3} + 3 f n^{2} + 2 f n} - \frac {2 A a^{2} n \left (- i c \tan {\left (e + f x \right )} + c\right )^{n} \tan {\left (e + f x \right )}}{f n^{3} + 3 f n^{2} + 2 f n} + \frac {4 i A a^{2} n \left (- i c \tan {\left (e + f x \right )} + c\right )^{n}}{f n^{3} + 3 f n^{2} + 2 f n} + \frac {4 i A a^{2} \left (- i c \tan {\left (e + f x \right )} + c\right )^{n}}{f n^{3} + 3 f n^{2} + 2 f n} - \frac {B a^{2} n^{2} \left (- i c \tan {\left (e + f x \right )} + c\right )^{n} \tan ^{2}{\left (e + f x \right )}}{f n^{3} + 3 f n^{2} + 2 f n} + \frac {i B a^{2} n^{2} \left (- i c \tan {\left (e + f x \right )} + c\right )^{n} \tan {\left (e + f x \right )}}{f n^{3} + 3 f n^{2} + 2 f n} - \frac {B a^{2} n \left (- i c \tan {\left (e + f x \right )} + c\right )^{n} \tan ^{2}{\left (e + f x \right )}}{f n^{3} + 3 f n^{2} + 2 f n} + \frac {4 i B a^{2} n \left (- i c \tan {\left (e + f x \right )} + c\right )^{n} \tan {\left (e + f x \right )}}{f n^{3} + 3 f n^{2} + 2 f n} + \frac {B a^{2} n \left (- i c \tan {\left (e + f x \right )} + c\right )^{n}}{f n^{3} + 3 f n^{2} + 2 f n} + \frac {4 B a^{2} \left (- i c \tan {\left (e + f x \right )} + c\right )^{n}}{f n^{3} + 3 f n^{2} + 2 f n} & \text {otherwise} \end {cases} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {could not integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 11.38, size = 193, normalized size = 1.77 \begin {gather*} -\frac {{\mathrm {e}}^{-e\,2{}\mathrm {i}-f\,x\,2{}\mathrm {i}}\,{\left (c-\frac {c\,\sin \left (e+f\,x\right )\,1{}\mathrm {i}}{\cos \left (e+f\,x\right )}\right )}^n\,\left (\frac {2\,a^2\,\left (2\,A-B\,2{}\mathrm {i}+A\,n+B\,n\,1{}\mathrm {i}\right )}{f\,n\,\left (n^2\,1{}\mathrm {i}+n\,3{}\mathrm {i}+2{}\mathrm {i}\right )}+\frac {2\,a^2\,{\mathrm {e}}^{e\,4{}\mathrm {i}+f\,x\,4{}\mathrm {i}}\,\left (A-B\,1{}\mathrm {i}\right )\,\left (n^2+3\,n+2\right )}{f\,n\,\left (n^2\,1{}\mathrm {i}+n\,3{}\mathrm {i}+2{}\mathrm {i}\right )}+\frac {2\,a^2\,{\mathrm {e}}^{e\,2{}\mathrm {i}+f\,x\,2{}\mathrm {i}}\,\left (n+2\right )\,\left (2\,A-B\,2{}\mathrm {i}+A\,n+B\,n\,1{}\mathrm {i}\right )}{f\,n\,\left (n^2\,1{}\mathrm {i}+n\,3{}\mathrm {i}+2{}\mathrm {i}\right )}\right )}{4\,{\cos \left (e+f\,x\right )}^2} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________